home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / HippoDraw / HippoDrawSrc1.1 / Hippo.subproj / Curve.m < prev    next >
Encoding:
Text File  |  1992-04-25  |  1.9 KB  |  69 lines

  1. #import "Curve.h"
  2. #import "draw.h"
  3.  
  4. @implementation Curve
  5.  
  6. - (float)arrowAngle:(int)corner
  7. /*
  8.  * Since our control points are at a 90 degree angle, we'll draw our arrows
  9.  * at 90 degree angles (however, this method breaks down a bit as the bounds
  10.  * get very skinny--perhaps a better one could be found).
  11.  */
  12. {
  13.     if (gFlags.downhill) {
  14.     switch (corner) {
  15.         case UPPER_LEFT: return 180.0;
  16.         case LOWER_RIGHT: return - 90.0;
  17.     }
  18.     } else {
  19.     switch (corner) {
  20.         case UPPER_RIGHT: return 0.0;
  21.         case LOWER_LEFT: return -90.0;
  22.     }
  23.     }
  24.     return 0.0;
  25. }
  26.  
  27. - drawLine
  28. /*
  29.  * Overridden from our superclass (Line).
  30.  * This is called from the draw method to actually do the drawing of the line,
  31.  * that way, we can inherit the arrow drawing, etc ...
  32.  */
  33. {
  34.     if (gFlags.downhill) {
  35.     PSCurve(bounds.origin.x, bounds.origin.y + bounds.size.height,
  36.         bounds.origin.x + bounds.size.width,
  37.         bounds.origin.y + bounds.size.height,
  38.         bounds.origin.x + bounds.size.width,
  39.         bounds.origin.y + bounds.size.height,
  40.             bounds.origin.x + bounds.size.width, bounds.origin.y);
  41.     } else {
  42.     PSCurve(bounds.origin.x, bounds.origin.y,
  43.         bounds.origin.x,
  44.         bounds.origin.y + bounds.size.height,
  45.             bounds.origin.x,
  46.         bounds.origin.y + bounds.size.height,
  47.             bounds.origin.x + bounds.size.width,
  48.         bounds.origin.y + bounds.size.height);
  49.     }
  50.     return self;
  51. }
  52.  
  53. - (BOOL)hit:(const NXPoint *)p
  54. /*
  55.  * Line only gets a hit if the mouse is within some tolerance of the line.
  56.  * Obviously that algorithm doesn't work for a curve.  We could come up
  57.  * with the proper algorithm to only hit a curve if it is within a tolerance,
  58.  * but that would be complicated so we take the easy way out and just
  59.  * get a hit if it is anywhere in the bounds.  It is unfortunate that we
  60.  * have to copy code from Graphic to accomplish this.  Perhaps a better
  61.  * way exists?
  62.  */
  63. {
  64.     return (!gFlags.locked && gFlags.active && NXMouseInRect(p, &bounds, NO));
  65. }
  66.  
  67. @end
  68.  
  69.